<?php

require_once 'User.php';
require_once 'UserForm.php';

class App_UserService
{
	protected $db;
	protected $user;
	
	public function __construct()
	{
		$options = array(
			'host' => 'localhost',
			'username' => 'root',
			'password' => '',
			'dbname' => 'xpic'
		);
		
		$this->db = Zend_Db::factory('PDO_MYSQL', $options);
		Zend_Db_Table_Abstract::setDefaultAdapter($this->db);
		$this->user = new User();
	}
	
	public function getUser($username)
	{
		$select = $this->user->select();
		$select->where('Username = ?', $username);
		
		return $this->user->fetchRow($select);
	}
	
	public function saveUser($userName, $pwd, $fName, $lName, $email)
	{
		$params = array(
			'Username' => $userName,
			'Password' => $pwd,
			'Firstname' => $fName,
			'Lastname' => $lName,
			'Email'	=> $email
		);
		
		$this->lastID = $this->user->insert($params);
	}
}